package com.lishe.lishe.lishe.module.excitation.adapter;

import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lishe.lishe.Imageloader.ImageLoaderUtils;
import com.lishe.lishe.R;
import com.lishe.lishe.lishe.module.excitation.bean.AchievementVoListObject;
import com.lishe.lishe.lishe.module.excitation.bean.company.CompanyInfo;

import java.util.List;

/**
 * Created by shino on 2017/12/21.
 */

public class SmallachievementAdapter extends RecyclerView.Adapter<SmallachievementAdapter.CompanyHolder> {
    private List<AchievementVoListObject> achievement;
    private ImageLoaderUtils utils;

    public SmallachievementAdapter(List<AchievementVoListObject> achievement) {
        this.achievement = achievement;
        utils=new ImageLoaderUtils();
    }

    @Override
    public CompanyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_small_achievement, null);
        CompanyHolder holder = new CompanyHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(CompanyHolder holder, final int position) {
        final AchievementVoListObject voListObject = achievement.get(position);
        holder.text.setText(voListObject.getAchieveName());
        utils.displayImage(voListObject.getAchieveImg(),holder.small_img);
        if (!voListObject.getUserId().equals("0")) {
            holder.background.setVisibility(View.GONE);
        }else{
            holder.background.setVisibility(View.VISIBLE);
        }

    }

    @Override
    public int getItemCount() {
        return achievement == null ? 0 : achievement.size();
    }

    class CompanyHolder extends ViewHolder {
        TextView text;
        ImageView background,small_img;

        public CompanyHolder(View itemView) {
            super(itemView);
            text = itemView.findViewById(R.id.text);
            background = itemView.findViewById(R.id.background);
            small_img = itemView.findViewById(R.id.small_img);
        }
    }
}
